<template>
  <div class="fixedDalary">
    <el-form label-width="120px">
      <el-form-item label="当前基本工资">
        <el-input
          v-model="formLabelAlign.currentBasicSalary"
          placeholder="当前基本工资"
          style="width: 60%"
          type="number"
        />
      </el-form-item>
      <el-form-item label="当前岗位工资">

        <el-input v-model="formLabelAlign.currentPostWage" placeholder="当前岗位工资" style="width: 60%" type="number" />
      </el-form-item>
      <el-form-item label="当前工资合计">

        <el-input v-model="present" placeholder="当前工资合计, 自动计算" style="width: 60%" :disabled="true" />
      </el-form-item>
      <el-form-item label="转正基本工资">
        <el-input
          v-model="formLabelAlign.correctionOfBasicWages"
          placeholder="转正基本工资"
          style="width: 60%"
          type="number"
        />
      </el-form-item>
      <el-form-item label="转正岗位工资">

        <el-input v-model="formLabelAlign.turnToPostWages" placeholder="转正岗位工资" style="width: 60%" type="number" />
      </el-form-item>
      <el-form-item label="转正工资合计">

        <el-input v-model="employment" placeholder="当前基本工资, 自动计算" style="width: 60%" :disabled="true" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="btnOK">确认</el-button>
        <el-button @click="onnoOK">关闭</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { postsalarysinit } from '@/api/salarys'
export default {
  props: {
    userId: {
      type: String,
      require: true,
      default: null
    }

  },
  data() {
    return {
      formLabelAlign: {}
    }
  },
  computed: {
    employment() {
      let base = 0
      if (this.formLabelAlign.correctionOfBasicWages != null) {
        base = Number(this.formLabelAlign.correctionOfBasicWages)
      }
      let post = 0
      if (this.formLabelAlign.turnToPostWages != null) {
        post = Number(this.formLabelAlign.turnToPostWages)
      }
      return base + post
    },
    present() {
      let base = 0
      if (this.formLabelAlign.currentBasicSalary != null) {
        base = Number(this.formLabelAlign.currentBasicSalary)
      }
      let post = 0
      if (this.formLabelAlign.currentPostWage != null) {
        post = Number(this.formLabelAlign.currentPostWage)
      }
      return base + post
    }
  },
  methods: {
    async btnOK() {
      this.formLabelAlign.userId = this.userId
      const data = this.formLabelAlign
      this.$message.success('定薪成功')
      await postsalarysinit(data)
      this.$emit('success')
      this.onnoOK()
    },
    onnoOK() {
      this.formLabelAlign = {}
      this.$emit('onDinxingshowData')
    }
  }
}
</script>

<style>

</style>
